package com.ngkj.zmfptes.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author ChenHN
 * @since 2021/11/2 creation
 **/
@Configuration
public class ESConfig {

    @Value("${elasticsearch.ip}")
    private String IP;

    @Value("${elasticsearch.port}")
    private int PORT;

    @Bean
    public RestHighLevelClient restHighLevelClient() {
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost(IP, PORT, "http"))
        );
        return restHighLevelClient;
    }



}
